package cifg;

import com.iid.flappybird.R;


import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

import cifgu.SKINADATPEW;


public class SKINADATPER extends Activity implements View.OnClickListener {

    private TextView tv_curScore;
    private TextView tv_historyScore;
    private TextView tv_startGame;
    private TextView tv_setting;
    private TextView tv_exit;
    private TextView tv_privacyPolicy;


    @SuppressLint("SetTextI18n")
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        requestWindowFeature(Window.FEATURE_NO_TITLE);

        setContentView(R.layout.loading);
        tv_curScore = findViewById(R.id.tv_curScore);
        tv_historyScore = findViewById(R.id.tv_historyScore);
        tv_startGame = findViewById(R.id.tv_startGame);
        tv_setting = findViewById(R.id.tv_setting);
        tv_exit = findViewById(R.id.tv_exit);
        tv_privacyPolicy = findViewById(R.id.tv_privacyPolicy);

        tv_startGame.setOnClickListener(this);
        tv_setting.setOnClickListener(this);
        tv_exit.setOnClickListener(this);
        tv_privacyPolicy.setOnClickListener(this);
    }

    private void startGame() {
        Intent intent = new Intent(SKINADATPER.this, GAMEACT.class);
        startActivity(intent);
    }

    @SuppressLint("SetTextI18n")
    private void refreshShowScore() {
        int[] data = getSettingData();
//        levelMessage.setText("SCORE: " + data[0] + "\nBEST: " + data[1]);
        tv_curScore.setText(getString(R.string.PreviousGameScore) + data[0]);
        tv_historyScore.setText(getString(R.string.HighestScoreInHistory) + data[1]);
    }

    @Override
    protected void onResume() {
        super.onResume();
        refreshShowScore();
    }

    private int[] getSettingData() {
        SharedPreferences gb_settings = getSharedPreferences(SKINADATPEW.GameBirdSettingsFile, 0);
        int last = gb_settings.getInt(SKINADATPEW.Settings_LevelLast, 0);
        int top = gb_settings.getInt(SKINADATPEW.Settings_LevelTop, 0);
        return new int[]{last, top};
    }

    @Override
    public void onClick(View view) {
        int viewID = view.getId();
        if (viewID == R.id.tv_startGame) {
            startGame();
        } else if (viewID == R.id.tv_setting) {
            BLSCDIDALOG bottomSheetDialog1 = new BLSCDIDALOG(this).init();
            bottomSheetDialog1.show();
        } else if (viewID == R.id.tv_privacyPolicy) {
            new DCFAEB(this)
                    .init()
                    .setClickBlankCancellation(true)
                    .setLayout()
                    .show();
        } else if (viewID == R.id.tv_exit) {
            finishAffinity();
            System.exit(0);
        }
    }
}
